<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .minyuan_red{padding: 4px;background-color: red;border-radius: 50%;font-size: 0!important;margin-right: 6px;position: relative;top: -4px;}
    .minyuan_lv{padding: 4px;background-color: #19BE6B;border-radius: 50%;font-size: 0!important;margin-right: 6px;position: relative;top: -4px;}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">账户名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">开户行</label>
                        <div class="layui-input-block">
                            <input type="text" name="accname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">账号</label>
                        <div class="layui-input-block">
                            <input type="text" name="accnum" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">交易月份</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="month" id="month" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ym">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">账户类型</label>
                        <div class="layui-input-block">
                            <div id="acctype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-block">
                            <select name="status" lay-filter="status">
                                <option value="">请选择</option>
                                <option value="1">正常</option>
                                <option value="0">停用</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>





    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('资金账户交易流水');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cai_account_tong),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                });
                xmselect_dan('acctype', res.data.acctype, res.data.is_acctype, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                });

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'chanid_name', title: '所属单位'}
                ,{field: 'name', title: '账户名称'}
                ,{field: 'accname', title: '开户行'}
                ,{field: 'accnum', title: '账号'}
                ,{field: 'acctype', title: '账户类型'}
                ,{field: 'seamonth', title: '交易月份'}
                ,{field: 'shou', title: '收入(元)',align:'right',totalRow: true,event: 'account_shou',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shou)+'</span>';
                    }}
                ,{field: 'zhi', title: '支出(元)',align:'right',totalRow: true,event: 'account_zhi',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.zhi)+'</span>';
                    }}
                ,{field: 'balance', title: '收支差额(元)',totalRow: true,align:'right',templet: function(d){
                        if(d.balance < 0){
                            return '<span class="colorhong">'+parseFormatNum(d.balance)+'</span>';
                        }else{
                            return parseFormatNum(d.balance);
                        }
                    }}
                ,{field:'status',title:'状态',templet: function(d){
                        if(d.status > 0){
                            return '<span><span class="minyuan_lv" style="font-size: 0!important"></span><span>正常</span></span>';
                        }else{
                            return '<span><span class="minyuan_red" style="font-size: 0!important"></span><span>停用</span></span>';
                        }
                    }}
            ]]
            , done: function (res) {
                soulTable.render(this);

            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            var month = $("#month").val();
            if(obj.event === 'account_shou'){
                openPage('../account_shou/tong.php?accname='+encodeURI(data.name)+'&monthquan='+encodeURI(month), '80%', '80%');
            }
            if(obj.event === 'account_zhi'){
                openPage('../account_zhi/tong.php?accname='+encodeURI(data.name)+'&monthquan='+encodeURI(month), '80%', '80%');
            }
        });

        listTableSearch(form, table);
    });



</script>
</body>
</html>
